import socket

def connect_to_server():
    # 创建TCP套接字
    client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    client_socket.connect(('127.0.0.1', 8080))  # 连接到服务器
    
    # 发送消息
    client_socket.send("你好，服务器！".encode('utf-8'))
    
    # 接收服务器响应
    response = client_socket.recv(1024).decode('utf-8')
    print(f"服务器响应: {response}")
    
    # 关闭连接
    client_socket.close()

if __name__ == "__main__":
    connect_to_server()